import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

export default new Router({
    routes: [
        {
            path: '/',
            redirect: '/dashboard'
        },
        {
            path: '/',
            component: () => import(/* webpackChunkName: "home" */ '../components/common/Home.vue'),
            meta: { title: '自述文件' },
            children: [
                {
                    path: '/home',
                    component: () => import(/* webpackChunkName: "dashboard" */ '../components/page/home/Dashboard.vue'),
                    meta: { title: '系统首页' }
                },

                {
                    path: '/userinfo',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/userAdministrstor/userInfo.vue'),
                    meta: { title: '用户信息' }
                },
                {
                    path: '/userauthority',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/userAdministrstor/resource/index'),
                    meta: { title: '用户权限' }
                },
                {
                    path: '/userrole',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/userAdministrstor/role/index'),
                    meta: { title: '角色列表' }
                },
                {
                    path: '/orderList',
                    component: () => import(/* webpackChunkName: "form" */ '../components/page/orderManager/order/index'),
                    meta: { title: '订单列表' }
                },
                {
                    path: '/orderSetting',
                    component: () => import(/* webpackChunkName: "form" */ '../components/page/orderManager/order/setting'),
                    meta: { title: '订单设置' }
                },
                {
                    path: '/order/orderDetail',
                    component: () => import(/* webpackChunkName: "form" */ '../components/page/orderManager/order/orderDetail'),
                    meta: { title: '订单详情' }
                },
                {
                    path: '/order/deliverOrderList',
                    component: () => import(/* webpackChunkName: "form" */ '../components/page/orderManager/order/deliverOrderList'),
                    meta: { title: '订单发货' }
                },
                {
                    path: '/product',
                    component: () => import(/* webpackChunkName: "form" */ '../components/page/product/product/index'),
                    meta: { title: '商品列表' }
                },
                {
                    path: '/product/add',
                    component: () => import(/* webpackChunkName: "form" */ '../components/page/product/product/add'),
                    meta: { title: '添加商品' }
                },
                {
                    path: '/product/update',
                    component: () => import(/* webpackChunkName: "form" */ '../components/page/product/product/components/ProductEditDetail'),
                    meta: { title: '编辑商品' }
                },
                {
                    path: '/product/classify',
                    component: () => import(/* webpackChunkName: "form" */ '../components/page/product/productClassify/index'),
                    meta: { title: '商品分类' }
                },
                {
                    path: '/content',
                    component: () => import(/* webpackChunkName: "form" */ '../components/page/content/index'),
                    meta: { title: '板块管理' }
                },
                {
                    path: '/redis',
                    component: () => import(/* webpackChunkName: "form" */ '../components/page/redis/index'),
                    meta: { title: '缓存管理' }
                },
                {
                    path: '/404',
                    component: () => import(/* webpackChunkName: "404" */ '../components/page/erro/404.vue'),
                    meta: { title: '404' }
                },
                {
                    path: '/403',
                    component: () => import(/* webpackChunkName: "403" */ '../components/page/erro/403.vue'),
                    meta: { title: '403' }
                },
                {
                    path: '/500',
                    component: () => import(/* webpackChunkName: "403" */ '../components/page/erro/500.vue'),
                    meta: { title: '500' }
                },
            ]
        },
        {
            path: '/login',
            component: () => import(/* webpackChunkName: "login" */ '../components/page/login/Login.vue'),
            meta: { title: '登录' }
        },
        {
            path: '*',
            redirect: '/404'
        }
    ]
});

const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
    if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
    return originalPush.call(this, location).catch(err => err)
}
